import axios from "./myAxios";
import {LIMIT ,BLOG_LIMIT} from "../config";

// 登录请求
export const reqLogin = ({username, password}) => axios(`/users/login/${username}/${password}`)

// 分类的分页请求
export const reqTypes = (page) => axios(`/types?page=${page}&limit=${LIMIT}`)

// 添加分类
export const reqAddType = (type) => axios.post(`/types`, type)

// 更新分类
export const reqUpdateType = (type) => axios.put("/types", type)

// 删除分类
export const reqDeleteType = (id) => axios.delete(`/types?id=${id}`)

// 标签的分页请求
export const reqTags = (page) => axios(`/tags?page=${page}&limit=${LIMIT}`)

// 添加标签
export const reqAddTag = (tag) => axios.post(`/tags`, tag)

// 更新标签
export const reqUpdateTag = (tag) => axios.put("/tags", tag)

// 删除标签
export const reqDeleteTag = (id) => axios.delete(`/tags?id=${id}`)

// 友链的分页请求
export const reqFriendLink = (page) => axios(`/links?page=${page}&limit=${LIMIT}`)

// 添加友链
export const reqAddFriendLink =(link) => axios.post("/links", link);

// 删除友链
export const reqDeleteLink = (id) => axios.delete(`/links/${id}`);

// 分页获得博客列表
export const reqBlogList = (page) => axios(`/blogs/page/${page}/${BLOG_LIMIT}`)

// 通过博客标题查询博客
export const reqBlogByTitle = (page, title) => axios(`/blogs?page=${page}&limit=${LIMIT}&title=${title}`)

// 删除博客
export const reqDeleteBlog = (id) => axios.delete(`/blogs/${id}`)

// 添加博客
export const reqAddBlog = (blog) => axios.post(`/blogs`, blog)

// 更新博客
export const reqUpdateBlog = (blog) => axios.put(`/blogs`, blog)

// 分页查询留言数据
export const reqMessages = (page) => axios(`/messages?limit=${LIMIT}&page=${page}`)

// 删除留言
export const reqDeleteMessage = (id) => axios.delete(`/messages/?ids=${id}`)

// 获取所有的分类数据
export const reqAllTypes = () => axios(`/types/all`)

// 获取所有的标签数据
export const reqAllTags = () => axios(`/tags/all`)

// 查询博文、包含博文详情
export const reqAllBlogData = (id) => axios(`/blogs/${id}`)

// 分页查询文件列表
export const reqAllFiles = (page) => axios(`/files/${page}/${LIMIT}`)

// 删除文件
export const reqDeleteFile = (id) => axios.delete(`/files/${id}`)

// 通过文件名查询文件
export const reqFilesByName = (name) => axios(`/files/${name}`)

// 分页查询网盘资源
export const reqResources = (page) => axios(`/resources/${page}/${LIMIT}`)

// 添加资源
export const reqAddResource  = (resource) => axios.post(`/resources`, resource)

// 更新资源
export const reqUpdateResource = (resource) => axios.put(`/resources`, resource)

// 删除资源
export const reqDeleteResource = (id) => axios.delete(`/resources/${id}`)

// 通过标题搜索资源
export const reqResourcesByTitle = (title) => axios(`/resources/${title}`)
